<?php
include(getabspath("include/certificate_of_origin_commercials_settings.php"));

function DisplayMasterTableInfo_certificate_of_origin_commercials($params)
{
	$detailtable=$params["detailtable"];
	$keys=$params["keys"];
	global $conn,$strTableName;
	$xt = new Xtempl();
	$oldTableName=$strTableName;
	$strTableName="certificate_of_origin_commercials";

//$strSQL = "SELECT id,   buyer_id,   account_id,   shipped_on,   shipment_date,   consigned_to,   sworn_to,   sworn_date,   chamber_of_commerce,   ref_id  FROM certificate_of_origin_commercials ";

$sqlHead="SELECT id,   buyer_id,   account_id,   shipped_on,   shipment_date,   consigned_to,   sworn_to,   sworn_date,   chamber_of_commerce,   ref_id";
$sqlFrom="FROM certificate_of_origin_commercials";
$sqlWhere="";
$sqlTail="";

$where="";
$mKeys = array();
$showKeys = "";

if($detailtable=="certificate_of_origin_items")
{
		$where.= GetFullFieldName("id")."=".make_db_value("id",$keys[1-1]);
	$showKeys .= " Id: ".$keys[1-1];
	$xt->assign('showKeys',$showKeys);
}
	if(!$where)
	{
		$strTableName=$oldTableName;
		return;
	}
	$str = SecuritySQL("Search");
	if(strlen($str))
		$where.=" and ".$str;

	$strWhere=whereAdd($sqlWhere,$where);
	if(strlen($strWhere))
		$strWhere=" where ".$strWhere." ";
	$strSQL= $sqlHead.' '.$sqlFrom.$strWhere.$sqlTail;

//	$strSQL=AddWhere($strSQL,$where);
	LogInfo($strSQL);
	$rs=db_query($strSQL,$conn);
	$data=db_fetch_array($rs);
	if(!$data)
	{
		$strTableName=$oldTableName;
		return;
	}
	$keylink="";
	$keylink.="&key1=".htmlspecialchars(rawurlencode(@$data["id"]));
	


//	id - 
			$value="";
				$value = ProcessLargeText(GetData($data,"id", ""),"field=id".$keylink);
			$xt->assign("id_mastervalue",$value);

//	buyer_id - 
			$value="";
				$value=DisplayLookupWizard("buyer_id",$data["buyer_id"],$data,$keylink,MODE_LIST);
			$xt->assign("buyer_id_mastervalue",$value);

//	account_id - 
			$value="";
				$value=DisplayLookupWizard("account_id",$data["account_id"],$data,$keylink,MODE_LIST);
			$xt->assign("account_id_mastervalue",$value);

//	shipped_on - 
			$value="";
				$value = ProcessLargeText(GetData($data,"shipped_on", ""),"field=shipped%5Fon".$keylink);
			$xt->assign("shipped_on_mastervalue",$value);

//	shipment_date - Short Date
			$value="";
				$value = ProcessLargeText(GetData($data,"shipment_date", "Short Date"),"field=shipment%5Fdate".$keylink);
			$xt->assign("shipment_date_mastervalue",$value);

//	consigned_to - 
			$value="";
				$value=DisplayLookupWizard("consigned_to",$data["consigned_to"],$data,$keylink,MODE_LIST);
			$xt->assign("consigned_to_mastervalue",$value);

//	sworn_to - 
			$value="";
				$value = ProcessLargeText(GetData($data,"sworn_to", ""),"field=sworn%5Fto".$keylink);
			$xt->assign("sworn_to_mastervalue",$value);

//	sworn_date - Short Date
			$value="";
				$value = ProcessLargeText(GetData($data,"sworn_date", "Short Date"),"field=sworn%5Fdate".$keylink);
			$xt->assign("sworn_date_mastervalue",$value);

//	chamber_of_commerce - 
			$value="";
				$value = ProcessLargeText(GetData($data,"chamber_of_commerce", ""),"field=chamber%5Fof%5Fcommerce".$keylink);
			$xt->assign("chamber_of_commerce_mastervalue",$value);

//	ref_id - 
			$value="";
				$value = ProcessLargeText(GetData($data,"ref_id", ""),"field=ref%5Fid".$keylink);
			$xt->assign("ref_id_mastervalue",$value);
	$xt->display("certificate_of_origin_commercials_masterlist.htm");
	$strTableName=$oldTableName;
}

?>